<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title></title>
        <link rel="stylesheet" href=<?php echo HOME_CSS.'reset.css' ?>>
        <link rel="stylesheet" href=<?php echo HOME_CSS.'login.css' ?>>
        <script type="text/javascript" src=<?php echo HOME_JS.'jquery.min.js' ?>></script>
        <script type="text/javascript" src=<?php echo HOME_JS.'md5.js' ?>></script>
    </head>
    <body>
        <div class="page">
            <div class="loginwarrp">
                <div class="logo">管理员登陆</div>
                <div class="login_form">
                    <li class="login-item">
                        <span>用户名：</span>
                        <input type="text" id="username" required="required" name="username" class="login_input">
                    </li>
                    <li class="login-item">
                        <span>邮　箱：</span>
                        <input type="text" id="email" required="required" name="email" class="login_input">
                    </li>
                    <li class="login-item">
                        <span>密　码：</span>
                        <input type="password" id="password" required="required" name="password" class="login_input">
                    </li>
                    <li class="login-sub">
                        <input type="submit" id="login" name="button" value="登录"/>
                    </li>
                </div>
            </div>
        </div>
    <script type="text/javascript">
        window.onload = function() {
            var config = {
                vx: 5,
                vy: 5,
                height: 2,
                width: 2,
                count: 300,
                color: "121, 162, 185",
                stroke: "100, 200, 180",
                dist: 6000,
                e_dist: 20000,
                max_conn: 10
            }
            CanvasParticle(config);
        }
    </script>
    <script type="text/javascript" src=<?php echo HOME_JS.'canvas-particle.js' ?>></script>
    <script>
    $(document).keyup(function(event){
        if(event.keyCode ==13){
            $("#login").trigger("click");
        }
    });
        $(function(){
            $("#login").click(function(){
                var uPattern = /^[a-zA-Z0-9_-]{4,16}$/;
                var ePattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                var pPattern = /^[a-zA-Z\d_]{8,}$/;
                var u_name = $("#username").val();
                var u_mail = $("#email").val();
                var u_pass = $("#password").val();
                if(!uPattern.test(u_name)){
                    alert('请输入正确的用户名');
                }else if(!ePattern.test(u_mail)){
                    alert('请输入正确的密邮箱');
                }else if(!pPattern.test(u_pass)){
                    alert('请输入正确的密码');
                }else{
                    data={
                        name:u_name,
                        email:u_mail,
                        password:md5(u_pass)
                    }
                    $.ajax({
                        url:'/blog_system/admin/index.php/Login/checkLogin',
                        type:'POST',
                        data:data,
                        success:function(result){
                            console.log(result);
                            if(result == 0){
                                alert('登陆信息错误！！');
                            }else if(result == 1){
                                window.location.href = "/blog_system/admin/index.php/User/getUserAll";
                            }
                        }
                    })
                }
            })
        });
    </script>
    </body>
</html>
